﻿#include <iostream>
#include <fstream>
#include <string>
#include <corecrt_io.h>
#include <windows.h>
#include <tchar.h>

#include "cat-app.hpp"


using namespace std;

static int run_program(fstream& logFile, int argc, char* argv[]) {
	int ret = -1;
	
	CATApp program(argc, argv);
	try {
		program.APPInit();

		ret = program.Run();
	
	}
	catch (const char* error) {
		
	
	}
	program.APPRelease();

	return ret;
};

static inline bool arg_is(const char* arg, const char* long_form,
	const char* short_form)
{
	return (long_form && strcmp(arg, long_form) == 0) ||
		(short_form && strcmp(arg, short_form) == 0);
}

int main(int argc, char* argv[]) {

	#ifndef _DEBUG
	#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
	#endif // DEBUG

	for (int i = 1; i < argc; i++) {
		if (arg_is(argv[i], "--help", "-h")) {
			std::cout
				<< "--help, -h: Get list of available commands.\n\n";
			exit(0);
		}
		else if (arg_is(argv[i], "--version", "-V")) {
			exit(0);
		}
	}
	fstream logFile;

	int ret = run_program(logFile, argc, argv);

	return ret;
}